#!/bin/bash



function agoraMain()
{
	source agora.sh
	echo "Chamando o agora Start" >> /tmp/gsd.log
	echo "A home atual é ${HOME}" >> /tmp/gsd.log
	TriggerType="${1}"

	CurrentGroup="$(miscQueryMemberCurrentGroup)"

	agoraTrigger "${CurrentGroup}" "${USER}" "${TriggerType}"
	
	echo "$(date) ${FUNCNAME}" >> /tmp/${USER}--${CurrentGroup}.txt
}




function agoraInit()
{

	function agoraHelp()
	{	
		echo 	"
		This function is called automatically after user connection
		agora '${TriggerType}'
		TriggerType = 'start'
		TriggerType = 'stop'

		agora help

		Lors de l'appel de la fonction agoraTrigger(),
		les utilisateurs d�clanchent un �v�nement de type
		'start' ou 'stop' selon qu'ils se connectent
		ou se d�connectent de leur environnement.
		"
	}

	InputParameter="${1}"

	if      [ "${InputParameter}" == 'start' ]; then

		agoraMain "${InputParameter}"

	elif    [ "${InputParameter}" == 'stop'  ]; then

		agoraMain "${InputParameter}"
	
	elif    [ "${InputParameter}" == 'help'  ]; then	

		agoraHelp

	else

		echo "Incorrect parameters"
		echo
		agoraHelp
	
	fi
}


agoraInit "${1}"

